import javax.swing.tree.TreeNode;
import java.util.LinkedList;
import java.util.Queue;

public class BinaryTree{
    public static void main(String[]args){
        int count = 0;
        int size1(TreeNode root){
            if (root == null){
                return = 0;
            }
            count++;
            size(root.left);
            size(root.right);
            return count;
        }

    }
}
int size(TreeNode root){
    if (root == null){
        return = 0;
    }
    return size(root.left) + size(root.right) + 1;
}

//获取叶子节点个数
int leafCount = 0;
void getLeafNodeCount(TreeNode root){
    if (root == null){
        return;
    }
    if (root.left == null && root.right == null){
        leafCount++;
    }
    getLeafNodeCount(root.left);
    getLeafNodeCount(root.right);
}

int getkLevelNodeCount(TreeNode root,int k){
    if (root == null || k <= 0){
        return 0;
    }
    if (k == 1){
        return 1;
    }
    return getkLevelNodeCount(root.left, k-1) + getkLevelNodeCount(root.right, k-1);
}


int k = 0;
int getHeight(TreeNode root){
    if (root == null){
        return 0;
    }
    int leftHeight = getHight(root.left);
    int rightHeight = getHight(root.right);
    return leftHeight > rightHeight ? leftHeight+1 : rightHeight+1;
}

TreeNode find(TreeNode root,char val) {
    if (root == null) {
        return null;
    }
    if (root.val == val) {
        return root;
    }

TreeNode ret = find(root.left, val){
        };
    if (ret != null){
        return ret;
    }
    ret = find(root.right, val);
    if (ret != null){
        return ret;
    }
    return null;

    boolean isCompleteTree(TreeNode root){
        if (root == null){
            return true;
        }
        Queue<TreeNode> queue = new LinkedList<>();
        queue.offer(root);
        while (!queue.isEmpty()){
            TreeNode cur = queue.poll();
            if (cur != null){
                queue.offer(cur.left);
                queue.offer(cur.right);
            }else{
                break;
            }
        }
        while (!queue.isEmpty()){
            TreeNode top = queue.peek();
            if (top != null){
                return false;
            }
            queue.poll();
        }
        return true;
    }


    public class Test{
        public static void main(String[] args){
            System.out.println("Hello,Java");
        }
    }






